/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gimreader;

/**
 *
 * @author pavel
 */
public class LogFiles {

    public LogFiles(String name) {
        this.LogFile = name;
        this.starttime = -1;
        this.endtime = -1;
        this.isGim = false;
    }
    int logid;
    String LogFile;
    long starttime;
    long endtime;
    int duration;
    boolean isGim;                  // TRUE if the log file is confirmed GIM_ETL
    boolean isChain;                // True if the log file is the continue of the previous file
                                    // (endtime of the previous file minus starttime of this file is less than 60 seconds)

    public void setName(String name) {
        this.LogFile = name;
    }

    public String getName() {
        return LogFile;
    }
    
    public void SetLogID( int i){
        this.logid= i;
    }
    
    public int GetLogID (){
        return logid;
    }
    
    // TRUE if it is confirmed gim_etl log
    public boolean IsGIM(){ 
        return isGim;
    }
    
    public void SetIsGIM (){
        this.isGim = true;    
    }
    
    long GetStart() {
        return starttime;
    }

    void SetStart(long starttime) {
        this.starttime = starttime;
        SetDuration();
    }

    long GetEnd() {
        return endtime;
    }

    void SetEnd(long endtime) {
        this.endtime = endtime;
        SetDuration();
    }

    int GetDuration() {
        return duration;
    }

    String GetNiceDuration(){
        if (duration > 86400000) {  
            return duration /1000 / 60 / 60/ 24 + "days " +(duration / 1000 / 60 / 60) % 24 + ":" + (duration / 1000 / 60) % 60 + ":" + duration / 1000 % 60;
        }else {
            return (duration / 1000 / 60 / 60) % 24 + ":" + (duration / 1000 / 60) % 60 + ":" + duration / 1000 % 60;
        }
    }
    
    void SetDuration() {
        if (this.endtime == 0 || this.starttime == 0) {
            this.duration = -1;
        } else {
            this.duration = (int) (this.endtime - this.starttime);
        }
    }
}
